﻿<Window x:Class="ScrumFactory.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:SF="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
        xmlns:SF_Windows="clr-namespace:ScrumFactory.Windows"
        xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
        
        xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
        
        SnapsToDevicePixels="True"        
        
        x:Name="mainWindow"
        
        ResizeMode="CanResize"
        
        WindowState="Maximized"
        
        Style="{StaticResource FactoryWindow}"
                
        Title="{Binding WindowTitle}" 
        mc:Ignorable="d"         
        d:DesignHeight="314"
        d:DesignWidth="452">

    <Grid Background="{StaticResource ApplicationBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition x:Name="bottomRow" Height="Auto"/>                
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="leftColumn" Width="Auto" MinWidth="250"/>                
            <ColumnDefinition x:Name="rightColumn" Width="*"/>            
        </Grid.ColumnDefinitions>

        <!-- LEFT PANELS-->
        <Border x:Name="leftPanelsBorder"
                Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Background="{StaticResource DockPanelStripBackground}">
                
            <TabControl     
                x:Name="leftPanels"                                                      
                TabStripPlacement="Right"                       
                Style="{StaticResource DockPanelTabControl}"
                ItemsSource="{Binding Path=DockLeftPanels}"/>            
        </Border>

        <GridSplitter
            x:Name="leftGridSplitter"
            VerticalAlignment="Stretch"
            Width="4"                                        
            Grid.Column="0" Grid.Row="1" Grid.RowSpan="2"                      
            Background="{StaticResource DockPanelStripBackground}" >                        
            <GridSplitter.Style>
                <Style>
                    <Style.Triggers>
                        <Trigger Property="GridSplitter.IsMouseOver" Value="True">
                            <Setter Property="GridSplitter.Effect">
                                <Setter.Value>
                                    <DropShadowEffect Color="Black" Direction="360" Opacity="0.3" BlurRadius="5" ShadowDepth="3"   />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <DataTrigger Binding="{Binding ElementName=leftPanels, Path=SelectedItem}" Value="{x:Null}">
                            <Setter Property="GridSplitter.IsEnabled" Value="False"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=leftPanels, Path=HasItems}" Value="False">
                            <Setter Property="GridSplitter.Visibility" Value="Collapsed"/>
                        </DataTrigger> 
                    </Style.Triggers>
                </Style>
            </GridSplitter.Style>
        </GridSplitter>

        
        <Grid VerticalAlignment="Stretch"              
            Grid.Column="1" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <SF_Windows:AlertMessage Grid.Row="0" Margin="5" Model="{Binding AlertMessageViewModel}"/>    

            <SF_Helpers:DockWindowContainer
                Grid.Row="1"
            x:Name="dockWindowContainer"            
            ChildWindows="{Binding ChildWindows}"            
            ScrollDuration="200"                 
            HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

                <Grid  Margin="10,0,5,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <DockPanel Grid.Row="0" HorizontalAlignment="Stretch">
                        <TextBlock 
                        Margin="0,10,0,0"
                        DockPanel.Dock="Left"                                                                        
                        Style="{StaticResource PanelMainTitle}"
                             Text="{Binding ElementName=projectPanels, Path=SelectedItem.PanelName, Mode=OneWay}"/>

                        <TextBlock                        
                        DockPanel.Dock="Right" VerticalAlignment="Bottom" HorizontalAlignment="Right"
                        Margin="0,0,5,-24"
                        FontFamily="{StaticResource WideFont}"
                        FontSize="{StaticResource BigFontSize}"
                        FontWeight="Bold"                        
                        Text="{Binding CurrentSprintLabel}">
                        <TextBlock.Foreground>
                            <SolidColorBrush Color="{StaticResource Green2Color}"/>
                        </TextBlock.Foreground>
                        </TextBlock>
                    </DockPanel>



                    <!-- PROJECT PANELS -->
                    <TabControl                                        
                        Grid.Row="1"
                        Margin="0,3,0,0"
                        x:Name="projectPanels"                                               
                        ItemsSource="{Binding ProjectPanels}"                    
                        SelectedItem="{Binding SelectedProjectTab}"
                        DisplayMemberPath="PanelName"
                        VerticalAlignment="Stretch">
                        <TabControl.ContentTemplate>
                            <DataTemplate>
                                <Border Style="{StaticResource ContentPanelBorder}" Padding="5" >
                                    <ContentPresenter Content="{Binding View}"/>
                                </Border>
                            </DataTemplate>
                        </TabControl.ContentTemplate>
                        <TabControl.Style>
                            <Style TargetType="{x:Type TabControl}" BasedOn="{StaticResource {x:Type TabControl}}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding SelectedProject}" Value="{x:Null}">
                                        <Setter Property="TabControl.IsEnabled" Value="False"/>
                                        <Setter Property="TabControl.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TabControl.Style>
                    </TabControl>



                </Grid>
            </SF_Helpers:DockWindowContainer>

        </Grid>  

     
    
        
            

        <!-- BOTTOM PANELS -->
        <Border Grid.Column="1" Grid.Row="2" Background="{StaticResource DockPanelStripBackground}">            
            <TabControl
                x:Name="bottomPanels"            
                Style="{StaticResource DockPanelTabControl}"            
                Background="{StaticResource DockPanelBottomBackground}"
                TabStripPlacement="Top"
                ItemsSource="{Binding Path=DockBottomPanels}"
                SelectionChanged="bottomPanels_SelectionChanged"/>                
        </Border>
        
        <GridSplitter
            HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
            Height="4" Grid.Column="1"
            Background="{StaticResource DockPanelStripBackground}">
            <GridSplitter.Style>
                <Style>
                    <Style.Triggers>
                        <Trigger Property="GridSplitter.IsMouseOver" Value="True">
                            <Setter Property="GridSplitter.Effect">
                                <Setter.Value>
                                    <DropShadowEffect Color="Black" Direction="90" Opacity="0.3" BlurRadius="5" ShadowDepth="3"   />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <DataTrigger Binding="{Binding ElementName=bottomPanels, Path=SelectedItem}" Value="{x:Null}">
                            <Setter Property="GridSplitter.IsEnabled" Value="False"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=bottomPanels, Path=HasItems}" Value="False">
                            <Setter Property="GridSplitter.Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </GridSplitter.Style>
        </GridSplitter>


        
        <Border
            Grid.Row="0" Grid.ColumnSpan="2" Panel.ZIndex="0"
            Background="{StaticResource MainWindowTitleBarBackgroundBrush}">
            <Menu Grid.Row="0" Grid.ColumnSpan="2"
                  Margin="3,0,0,5"
                  Foreground="{StaticResource TopMenuBrush}"
                  Background="Transparent">
                <MenuItem                    
                    Header="{x:Static props:Resources.New_project}" Command="{Binding CreateProjectCommand}" />                
            </Menu>
            <Border.Effect>
                <DropShadowEffect Direction="270" Opacity="0.5" ShadowDepth="1" BlurRadius="3" />
            </Border.Effect>
        </Border>

        <Border Background="Black" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="2" Opacity="0.5">
            <Border.Style>
                <Style>
                    <Setter Property="Border.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=mainWindow, Path=IsActive}" Value="False">
                            <Setter Property="Border.Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
        </Border>


    </Grid>

        
    
</Window>
 